#!/bin/sh

# 26.02.2006 Volker Quetschke
# Test if dmake complains about circular dependencies when using
# infered .INCLUDE targets
# (issue 62118)

: ${DMAKEPROG:=dmake}
file1="mfile1.mk"
file2="mytarget.dpcc"
tmpfiles="$file1 $file2"

trap '{ echo "trapped signal - removing temporary files" ; rm -rf $tmpfiles ; }' 1 2 3 15

# Remove files from prior failed run
rm -rf $tmpfiles

# Remember to quote variables in generated makefiles( $ -> \$ ).
cat > $file1 <<EOT
# Verify that makefile generation is finished when using it
SHELL*:=/bin/sh 
SHELLFLAGS*:=-ce

%.dpcc :
	@echo making: \$@
	@+echo AA=123 > \$@

.INCLUDE : mytarget.dpcc

ALL : mytarget.dpcc

EOT

output=`eval ${DMAKEPROG} -r -f $file1`
result=$?

test $result -eq 0 && echo "Success - Cleaning up" && rm -f ${tmpfiles}
test $result -ne 0 && echo "Failure! Invalid circular dependency detected."
exit $result
